#include<vector>
using std::vector;


class Solution {
public:
    int maxArea(vector<int>& height) {
        int maxarea = 0;
        int p0 = 0, p1 = height.size() - 1;
        while (p0 < p1) {
            int area = (p1 - p0) * (height[p0] < height[p1] ? height[p0] : height[p1]);
            if (area > maxarea) maxarea = area;
            if (height[p0] < height[p1]) p0 ++;
            else p1--;
        }
        return maxarea;
    }
};